/**
 * 专题图层 - 无线预警广播站
 */
export default {
    data() {
        return {
        }
    },
    computed: {
        basin() {
            return this.$store.getters.basin
        }
    },
    watch: {
        basin: {
            handler: function(name) {
                this.$nextTick(() => {
                    this.creatWXYJGBZ()
                })
            },
            immediate: true
        }
    },
    created() {
        this.entitiesWXYJGBZ = []
    },
    methods: {
        creatWXYJGBZ() {
            if (this.layerList2[1].children.WXYJGBZ.show) {
                this.clearWXYJGBZ()
                var url = `${mapConfig.resUrlPre}/geojson/${this.basin}/WXYJGBZ.json`
                this.$axios.get(url).then(res => {
                    res.data.features.forEach((item) => {
                        var coordinates = item.geometry.coordinates
                        var entity = {
                            eventName: 'NAME',
                            lid: 'WXYJGBZ',
                            prop: item.properties,
                            position: Cesium.Cartesian3.fromDegrees(
                                coordinates[0],
                                coordinates[1]
                            ),
                            billboard: {
                                image: this.layerList2[1].children.WXYJGBZ.icon,
                                horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
                                verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
                                heightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
                                distanceDisplayCondition: new Cesium.DistanceDisplayCondition(0.0, this.$config.mapConfig.pb_far),
                                width: this.$config.mapConfig.billboardSize,
                                height: this.$config.mapConfig.billboardSize
                            }
                        }
                        this.entitiesWXYJGBZ.push(this.$viewer.entities.add(entity))
                    })
                    // this.initEvent()
                })
            } else {
                this.clearWXYJGBZ()
            }
        },
        clearWXYJGBZ() {
            if (this.entitiesWXYJGBZ && this.entitiesWXYJGBZ.length > 0) {
                this.entitiesWXYJGBZ.forEach(item => {
                    this.$viewer.entities.remove(item)
                })
                this.entitiesWXYJGBZ = []
            }
        },
        /**
         * 获取tip内容配置项
         * @param {Object} data 专题图层要素数据
         * @returns {Object}
         */
        getRemarksWXYJGBZ(data) {
            return [
                { name: null, value: data.NAME }
                // { name: '房屋数', value: data.HOUSE },
                // { name: '人口数', value: data.PCOUNT },
            ]
        }
    }
}
